import request from '@/utils/request'
const baseURL = '/auth'
const baseURL_record = '/auth/record'
export default {
  // 登录
  login(data) {
    return request({
      url: baseURL + '/login',
      method: 'POST',
      data: data
    })
  },
  // 注册
  register(data) {
    return request({
      url: baseURL + '/register',
      method: 'POST',
      data
    })
  },
  // 获得图形验证码
  getImgCode() {
    return request({
      url: baseURL + '/getImgCode',
      method: 'POST'
    })
  },
  checkImgCode(code) {
    return request({
      url: baseURL + '/checkImgCode',
      method: 'GET',
      params: {
        code
      }
    })
  },
  // aly发送短信
  sendSmsCode(data) {
    return request({
      url: baseURL + '/sendSmsCode',
      method: 'POST',
      data: data
    })
  },
  // 检查短信验证码·
  checkSmsCode(code, phone) {
    return request({
      url: baseURL + '/checkSmsCode',
      method: 'GET',
      params: {
        code,
        phone
      }
    })
  },
  // 根据token获得用户信息
  getUserInfo() {
    return request({
      url: baseURL + '/getUserInfo',
      method: 'GET'
    })
  },
  // 根据userId获得用户信息
  getUserInfobyId(userId) {
    return request({
      url: baseURL,
      method: 'GET',
      params: {
        userId
      }
    })
  },
  // 修改头像
  updateAvatar(userInfo) {
    return request({
      url: baseURL + '/updateAvatar',
      method: 'POST',
      data: userInfo
    })
  },
  // 添加职务
  addDuties(data) {
    return request({
      url: baseURL + '/addDuties',
      method: 'POST',
      data
    })
  },
  // 添加公司
  addCompany(data) {
    return request({
      url: baseURL + '/addCompany',
      method: 'POST',
      data
    })
  },
  // 用户对职位感兴趣
  recordAddPosts(userId, postsId) {
    return request({
      url: baseURL_record + '/add/posts',
      method: 'POST',
      params: {
        userId,
        postsId
      }
    })
  },
  recordAddCompany(userId, companyId) {
    return request({
      url: baseURL_record + '/add/company',
      method: 'POST',
      params: {
        userId,
        companyId
      }
    })
  },
  recordAddConnect(userId, postsId) {
    return request({
      url: baseURL_record + '/add/connect',
      method: 'POST',
      params: {
        userId,
        postsId
      }
    })
  },
  recordDeletePosts(userId, postsId) {
    return request({
      url: baseURL_record + '/delete/posts',
      method: 'POST',
      params: {
        userId,
        postsId
      }
    })
  },
  recordDeleteCompany(userId, companyId) {
    return request({
      url: baseURL_record + '/delete/company',
      method: 'POST',
      params: {
        userId,
        companyId
      }
    })
  },
  recordCheckPosts(userId, postsId) {
    return request({
      url: baseURL_record + '/check/posts',
      method: 'GET',
      params: {
        userId,
        postsId
      }
    })
  },
  recordCheckCompany(userId, companyId) {
    return request({
      url: baseURL_record + '/check/company',
      method: 'GET',
      params: {
        userId,
        companyId
      }
    })
  },
  logout(userId) {
    return request({
      url: baseURL + '/logout',
      method: 'POST',
      data: userId
    })
  },
  recordgetPosts(userId, page, size) {
    return request({
      url: baseURL_record + '/get/posts',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  recordgetCompany(userId, page, size) {
    return request({
      url: baseURL_record + '/get/company',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  recordgetConnect(userId, page, size) {
    return request({
      url: baseURL_record + '/get/connect',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  },
  getCompanyByUserId(userId) {
    return request({
      url: baseURL + '/get/company',
      method: 'GET',
      params: {
        userId
      }
    })
  }
}
